package com.springboot.test.web.manage;

import com.baomidou.mybatisplus.extension.api.R;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.springboot.test.common.response.Response;
import com.springboot.test.service.UserService;
import com.springboot.test.service.param.UserPageParam;
import com.springboot.test.service.result.UserResult;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("manage/user")
public class ManageUserController {

    @Resource
    private UserService userService;

    /**
     * 用户分页
     * @param param
     * @return
     */
    @PostMapping("page")
    public Response<Page<UserResult>> entityList(@RequestBody UserPageParam param) {
        return Response.success(userService.resultPage(param));
    }

    @PostMapping("batch_block")
    public Response<Boolean> batchBlock(@RequestBody List<String> ids){
        return Response.success(userService.batchBlock(ids));
    }

    @GetMapping("update_status")
    public Response<Boolean> updateStatus(Integer status,String userId){
        return Response.success(userService.updateStatus(status,userId));
    }

    @GetMapping("delete")
    public Response<Boolean> delete(String userId){
        return Response.success(userService.delete(userId));
    }

    @GetMapping("login")
    public Response<String> login(String username,String password){
        return Response.success(userService.adminLogin(username,password));
    }

    @GetMapping("count")
    public Response<Integer> count(){
        return Response.success(userService.count());
    }

}
